const path = require("path");
// const defaultSettings = require('./src/settings.js')

function resolve(dir) {
	return path.join(__dirname, dir);
}

module.exports = {
	// productionSourceMap: false,
	devServer: {
		port: "80",
		disableHostCheck: true,
		proxy: {
			// "/api": {
			// 	// target: "https://agent.lsjzg.com/api/",
			// 	// target: 'http://agent-test.lsjzg.com/api/',
			// 	target: "http://192.168.2.124:9100",
			// 	changeOrigin: true,
			// 	pathRewrite: {
			// 		// "^/api": "/"
			// 		"^/api": "/agent-api"
			// 	}
			// },
			"/api": {
				target: "http://192.168.80.95:31002",
				changeOrigin: true,
				pathRewrite: {
					"^/api": "/agent-api"
				}
			}
		}
	},
	chainWebpack: function(config) {
		if (process.env.use_analyzer) {
			config
				.plugin("webpack-bundle-analyzer")
				.use(require("webpack-bundle-analyzer").BundleAnalyzerPlugin);
		}
		config.module
			.rule("pug")
			.test(/\.pug$/)
			.use("pug-html-loader")
			.loader("pug-html-loader")
			.end();
		config.module
			.rule("svg")
			.exclude.add(resolve("src/plugins/icons"))
			.end();
		config.module
			.rule("icons")
			.test(/\.svg$/)
			.include.add(resolve("src/plugins/icons"))
			.end()
			.use("svg-sprite-loader")
			.loader("svg-sprite-loader")
			.options({
				symbolId: "icon-[name]"
			})
			.end();
	}
};
